<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Cache-Control" content="no-cache">
<meta http-equiv="Expires" content="0">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet" href="../css/style.css">
<title>Archive Login</title>
<script language="JavaScript" src="../js/jquery.js"></script>
<script language="javascript"  src="../js/cloud.js"></script>
<script language="javascript">
$(function(){
    $('.loginbox').css({'position':'absolute','left':($(window).width()-692)/2});
	$(window).resize(function(){  
    	$('.loginbox').css({'position':'absolute','left':($(window).width()-692)/2});
   	});
}); 
	

function login(){
    var username = $(".loginuser").val();
    var password = $(".loginpwd").val();
    var parameter = {username:username,password:password};
	try{
		$.ajax({
	        url: '../user/login/validate',
	        data:JSON.stringify(parameter),
	        beforeSend: function(request) {
	        	var accessToken = localStorage.getItem('accessToken');
	            request.setRequestHeader("accessToken",accessToken );
	        },
	        dataType: 'JSON',
	        async: false,
	        contentType:'application/json;charset=utf-8',
	        type: 'POST',
	        success: function(data, textStatus, response) {
	            console.log(JSON.stringify(data));
	            var accessToken = response.getResponseHeader('accessToken');
	            var refreshToken = response.getResponseHeader('refreshToken');
	            var expiresIn = response.getResponseHeader('expiresIn');
	            var isBusiManage = response.getResponseHeader('isBusiManage');
	            localStorage.setItem('accessToken',accessToken);
	            localStorage.setItem('refreshToken',refreshToken);
	            localStorage.setItem('expiresIn',expiresIn);	            
	            localStorage.setItem('isBusiManage',isBusiManage);	            
	            if (data.status == 0) {
						window.parent.location.href="../application/home";
	            }else{
	            	alert(data.message);
	            	//$(".tipright").find("p").html(data.message);
	            	//$(".tipright").find("cite").html("");		
	            	//$(".tip").fadeIn(200);
	            	//$(".sure").click(function(){	            		
	            	//	$(".tip").fadeOut(100);
	            	//});
            	  	//$(".tiptop a").click(function(){
            		//  $(".tip").fadeOut(200);
            		//});
	            }	            
	        },
	        error: function () {
	            alert("error");
	        }
	    });
	
	}
	catch(e){
	    alert(e.message);
	}
}


</script> 
</head>
<body style="background-color:#1c77ac; background-image:url(../images/login/light.png); background-repeat:no-repeat; background-position:center top; overflow:hidden;">
 
 
 	<div id="mainBody">
      <div id="cloud1" class="cloud"></div>
      <div id="cloud2" class="cloud"></div>
    </div>
    
	<div class="logintop">    
		<span>欢迎登录</span>    
	    <ul>
		    <li><a href="#">回首页</a></li>
		    <li><a href="#">帮助</a></li>
		    <li><a href="#">关于</a></li>
	    </ul>
    </div>
    
    <div class="loginbody">
	    <span class="systemlogo"></span> 
	    <div class="loginbox">
		    <ul>
			    <li>
			    	<input name="" type="text" class="loginuser" value="" onclick="JavaScript:this.value=''"/>
			    </li>
			    <li>
			    	<input name="" type="password" class="loginpwd" value="" onclick="JavaScript:this.value=''"/>
			    </li>
			    <li>
			    	<input name="" type="button" class="loginbtn" value="登录"  onclick="login()"  />
				    <label><input name="" type="checkbox" value="" checked="checked" />记住密码</label>
				    <label><a href="#">注册</a></label>
			    </li>
		    </ul>
	    </div>
    </div>
    <div class="loginbm">版权所有 </div>
</body>
</html>